import * as React from 'react'
import { Helmet } from 'react-helmet'
import { connect } from 'react-redux'
import { BrowserRouter as Router, Redirect, Switch } from 'react-router-dom'
import router, { NestedRoute, StatusRoute } from './router'
import Context, { context } from './config/context'
function App(props) {
    const {} = props
    return (
        <Context.Provider value={context}>
            <Helmet>
                <title>( ゜- ゜)つロ干杯~</title>
                <meta name="title" content="Bilibili-( ゜- ゜)つロ干杯~" />
                <meta name="keywords" content="React,服务端渲染" />
                <meta name="description" content="高仿Bilibili" />
            </Helmet>
            <Router>
                <Switch>
                    {router.map((route, i) => (
                        <NestedRoute {...route} key={i} />
                    ))}
                    <Redirect from="/" to="/index" exact={true} />
                    <StatusRoute code={404}>
                        <div>
                            <h1>Not Found</h1>
                        </div>
                    </StatusRoute>
                </Switch>
            </Router>
        </Context.Provider>
    )
}
export default connect(
    function mapStateToProps(state) {
        return state
    },
    function mapDispatchToProps(dispatch) {
        return { dispatch }
    }
)(App)
